package interview.huawei.training.p27;

import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        String[] params = str.split(" ");
        int n = Integer.parseInt(params[0]);
        String target = params[params.length - 2];
        ArrayList<String> brotherList = new ArrayList<>();
        for(int i = 1; i <= n; i++) {
            if(target.length() == params[i].length() && !target.equals(params[i])) {
                ArrayList<Character> chList = new ArrayList<>();
                for (char ch : params[i].toCharArray()) {
                    chList.add(ch);
                }
                for(int j = 0; j < target.length(); j++) {
                    chList.remove((Character) target.charAt(j));
                }
                if(chList.size() == 0)
                    brotherList.add(params[i]);
            }
        }
        Collections.sort(brotherList);
        System.out.println(brotherList.size());
        int index = Integer.parseInt(params[params.length - 1]) - 1;
        if(index < brotherList.size())
            System.out.println(brotherList.get(index));
    }
}